/* QtLua -- Lua bindings for Qt
   Copyright (C) 2011, Jarek Pelczar

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 3 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General
   Public License along with this library; if not, write to the
   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301 USA

*/

#include "qluascriptbreakpointswidget_p.h"
#include "qluascriptbreakpointmodel_p.h"
#include "qluascriptsdebuggerscriptmodel_p.h"
#include <QVBoxLayout>
#include <QCompleter>

QLuaScriptBreakpointsWidget::QLuaScriptBreakpointsWidget(QWidget *parent) :
    QLuaScriptBreakpointsWidgetInterface(parent)
{
    m_breakpoints = 0;
    m_scripts = 0;

    m_view = new QTreeView(this);

    m_view->setEditTriggers(QAbstractItemView::AllEditTriggers);
    m_view->setRootIsDecorated(false);
    m_view->setSelectionBehavior(QAbstractItemView::SelectRows);

    QVBoxLayout * lay = new QVBoxLayout(this);
    lay->setSpacing(0);
    lay->setMargin(0);
    lay->addWidget(m_view);
}

QLuaScriptBreakpointModel * QLuaScriptBreakpointsWidget::breakpointsModel() const
{
    return m_breakpoints;
}

void QLuaScriptBreakpointsWidget::setBreakpointsModel(QLuaScriptBreakpointModel * model)
{
    m_breakpoints = model;
    m_view->setModel(model);
}

QLuaScriptsDebuggerScriptModel * QLuaScriptBreakpointsWidget::scriptsModel() const
{
    return m_scripts;
}

void QLuaScriptBreakpointsWidget::setScriptsModel(QLuaScriptsDebuggerScriptModel * model)
{
    m_scripts = model;
    QCompleter * completer = new QCompleter(model, this);
    completer->setCompletionRole(Qt::DisplayRole);
}
